<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>

<body>
    <div id="root">
        {{fullName()}}
        <br>
        {{computedFullName}}
        <br>
        {{age}}
    </div>
    <script>
        var vm = new Vue({
            el: '#root',
            data: {
                firstName: 'Yu',
                lastName: 'Lee',
                age: 23
            },
            computed: {
                computedFullName: function () {
                    console.log(" computed 计算了一次")
                    return this.firstName + " " + this.lastName;
                }
            },
            methods: {
                fullName: function () {
                    console.log(" methods 计算了一次")
                    return this.firstName + " " + this.lastName;
                }
            },
            watch: {
                firstName: function () {
                    console.log(" watch 计算了一次");
                    return this.firstName + " " + this.lastName;
                },
                lastName: function () {
                    console.log(" watch 计算了一次");
                    return this.firstName + " " + this.lastName;
                }
            }
        })
    </script>
</body>

</html>